package com.example.acceletracks;

import java.io.Serializable;
import java.util.LinkedList;
import java.util.List;

import com.google.android.gms.maps.model.LatLng;

public class AcceleRoute implements Serializable {

	private static final long serialVersionUID = 1L;

	List<Node> nodeList;
		
	public AcceleRoute() {
        nodeList = new LinkedList<Node>();
	}
	
	public AcceleRoute(List<Node> list) {
        this.nodeList = list;
	}
	public void addNode(Node node)
	{
		nodeList.add(node);
	}
	
	public void addNodes(List<Node> list)
	{
		nodeList.addAll(list);
	}
	
	public String toString() {
		
		StringBuffer buffer = new StringBuffer();
		
		for(int i=0; i<nodeList.size(); i++)
		{
			float[] xyz=nodeList.get(i).getXyz();
			float time=nodeList.get(i).getTime();
			float diff=nodeList.get(i).getDiff();
			float speed=nodeList.get(i).getSpeed();
			LatLng ll=nodeList.get(i).getLatlng();
			
			buffer.append(xyz[0] + ";" + xyz[1] + ";" + xyz[2] + ";");
			buffer.append(time + ";");
			buffer.append(diff + ";");
			buffer.append(speed + ";");
			buffer.append(ll.latitude + ";" + ll.longitude + "\n");

		}
		
		if(buffer.length()>0)
		buffer.deleteCharAt(buffer.length()-1);
		
		return buffer.toString();
	}

}
